#include "AppDelegate.h"
#include "CSplashScene.h"
#include "HelloWorldScene.h"
#include "CGameManager.h"
#include "Constants.h"


USING_NS_CC;
static CCSize designResolutionSize = CCSizeMake(480,800);
AppDelegate::AppDelegate() {

}

AppDelegate::~AppDelegate() 
{
}

bool AppDelegate::applicationDidFinishLaunching() {

    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionExactFit);

    pDirector->setDisplayStats(false);

    pDirector->setAnimationInterval(1.0 / 60);

    CGameManager::Instance()->RunScene(SCENE_INTRO);

    return true;
}

void AppDelegate::applicationDidEnterBackground() {
	CCLog("applicationDidEnterBackground");
    CCDirector::sharedDirector()->stopAnimation();
    CCDirector::sharedDirector()->pause();
    CGameManager::Instance()->stopSound();
}

void AppDelegate::applicationWillEnterForeground() {
	CCLog("applicationWillEnterForeground");
    CCDirector::sharedDirector()->startAnimation();
    CCDirector::sharedDirector()->resume();
    CGameManager::Instance()->playSound();
}

void AppDelegate::setListener(CallbackListener *listener){
	mListener = listener;
}

void AppDelegate::shareViaFacebook(){
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	mListener->shareViaFacebookCallback();
#endif
}

void AppDelegate::rateThisApp(){
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	mListener->rateThisApplicationCallback();
#endif
}

